package org.groupg.filetodb.model.database;

/**
 * 数据库基本信息
 */

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

import java.util.ArrayList;
import java.util.List;

/**
 * 数据库元数据信息容器。
 */
public class DatabaseMetadataInfo {
    /**
     * 数据库的表信息
     */
    private List<Table> tables = new ArrayList<>();
    /**
     * 数据库的字段信息
     */
    private List<Column> columns = new ArrayList<>();
    /**
     * 数据库表的主键信息
     */
    private List<PrimaryKey> primaryKeys = new ArrayList<>();
    /**
     * 数据库的类型信息
     */
    private List<TypeInfo> typeInfos = new ArrayList<>();
    /**
     * 数据库的索引信息
     */
    private List<IndexInfo> indexInfos = new ArrayList<>();
    /**
     * 数据库的函数信息
     */
    private List<Function> functions = new ArrayList<>();
    /**
     * 数据库的函数字段信息
     */
    private List<FunctionColumn> functionColumns = new ArrayList<>();

    /**
     * 数据库存储过程信息
     */
    private List<Procedure> procedures = new ArrayList<>();
    /**
     * 数据库存储过程的字段信息
     */
    private List<ProcedureColumn> procedureColumns = new ArrayList<>();

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("tables", tables.size())
                .add("columns", columns.size())
                .add("primaryKeys", primaryKeys.size())
                .add("typeInfos", typeInfos.size())
                .add("indexInfos", indexInfos.size())
                .add("functions", functions.size())
                .add("functionColumns", functionColumns.size())
                .add("procedures", procedures.size())
                .add("procedureColumns", procedureColumns.size())
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        DatabaseMetadataInfo that = (DatabaseMetadataInfo) o;
        return Objects.equal(getTables(), that.getTables()) && Objects.equal(getColumns(), that.getColumns()) && Objects.equal(getPrimaryKeys(), that.getPrimaryKeys()) && Objects.equal(getTypeInfos(), that.getTypeInfos()) && Objects.equal(getIndexInfos(), that.getIndexInfos()) && Objects.equal(getFunctions(), that.getFunctions()) && Objects.equal(getFunctionColumns(), that.getFunctionColumns()) && Objects.equal(getProcedures(), that.getProcedures()) && Objects.equal(getProcedureColumns(), that.getProcedureColumns());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getTables(), getColumns(), getPrimaryKeys(), getTypeInfos(), getIndexInfos(), getFunctions(), getFunctionColumns(), getProcedures(), getProcedureColumns());
    }

    public List<Table> getTables() {
        return tables;
    }

    public void setTables(List<Table> tables) {
        this.tables = tables;
    }

    public List<Column> getColumns() {
        return columns;
    }

    public void setColumns(List<Column> columns) {
        this.columns = columns;
    }

    public List<PrimaryKey> getPrimaryKeys() {
        return primaryKeys;
    }

    public void setPrimaryKeys(List<PrimaryKey> primaryKeys) {
        this.primaryKeys = primaryKeys;
    }

    public List<TypeInfo> getTypeInfos() {
        return typeInfos;
    }

    public void setTypeInfos(List<TypeInfo> typeInfos) {
        this.typeInfos = typeInfos;
    }

    public List<IndexInfo> getIndexInfos() {
        return indexInfos;
    }

    public void setIndexInfos(List<IndexInfo> indexInfos) {
        this.indexInfos = indexInfos;
    }

    public List<Function> getFunctions() {
        return functions;
    }

    public void setFunctions(List<Function> functions) {
        this.functions = functions;
    }

    public List<FunctionColumn> getFunctionColumns() {
        return functionColumns;
    }

    public void setFunctionColumns(List<FunctionColumn> functionColumns) {
        this.functionColumns = functionColumns;
    }

    public List<Procedure> getProcedures() {
        return procedures;
    }

    public void setProcedures(List<Procedure> procedures) {
        this.procedures = procedures;
    }

    public List<ProcedureColumn> getProcedureColumns() {
        return procedureColumns;
    }

    public void setProcedureColumns(List<ProcedureColumn> procedureColumns) {
        this.procedureColumns = procedureColumns;
    }
}


